package org.xxforest.game.core.scenes.scene2d.events.type;

import org.xxforest.game.core.scenes.scene2d.XXNode;
import org.xxforest.game.core.scenes.scene2d.events.XXEvent;
import org.xxforest.game.core.scenes.scene2d.events.XXEventType;

import com.badlogic.gdx.utils.Pools;

public class XXFocusEvent implements XXEvent{

	private XXNode lostFocusNode ;
	private XXNode obtainFocusNode ;
	private XXEventType eventType ;
	
	public static XXFocusEvent create() {
		return Pools.obtain(XXFocusEvent.class);
	}

	public XXFocusEvent lostFocusNode(XXNode node) {
		eventType = XXEventType.LOST_FOUCS ;
		this.lostFocusNode = node ;
		return this ;
	}
	
	public XXFocusEvent obtainFocusNode(XXNode node){
		eventType = XXEventType.FOUCS_ON ;
		this.obtainFocusNode = node ;
		return this ;
	}

	@Override
	public XXEventType getEventType() {
		return eventType;
	}

	@Override
	public void dispose() {
		this.lostFocusNode = null ;
		this.obtainFocusNode = null ;
		this.eventType = null ;
		Pools.free(this);
	}

	public XXNode getLostFocusNode() {
		return lostFocusNode;
	}

	public XXNode getObtainFocusNode() {
		return obtainFocusNode;
	}

	public boolean isLostFocus(XXNode node){
		return this.lostFocusNode == node ;
	}
	
	public boolean isObtainFocus(XXNode node){
		return this.obtainFocusNode == node ;
	}
}
